#{extends 'main.html' /}
<div>
#{if event.sprint}
<h2>
	<a style ="color:#400040;" href=" @{Projects.showProject(event.sprint.project.getEntityId())}">${event.sprint.project.name}</a> > 
	<a style ="color:#400040;" href=" @{Events.showSprints(event.sprint.project.getEntityId())}">Sprints</a> > 
	<a style ="color:#400040;" href="@{Events.showSprint(event.sprint.getEntityId())}">${event.sprint.name}</a> > 
	<a style ="color:#400040;" href="@{Events.showSprintEvents(event.sprint.getEntityId())}">Events</a> > ${event.name}
</h2><hr/>
#{/if}
#{else}
<h2>
	<a style ="color:#400040;" href="@{Projects.showProject(event.project.getEntityId())}">${event.project.name}</a> > 
	<a style ="color:#400040;" href="@{Events.showProjectEvents(event.project.getEntityId())}">Events</a> > ${event.name}
</h2><hr/>
#{secure.check 'Delete an event'}
	<a href="javascript:showDialogHelper('Confirmation','Are you sure you want to delete this event?',true,'@{Events.deleteEvent(event.getEntityId())}','prompt');" >Delete Event</a><hr/> 
#{/secure.check}
#{/else}
	<b>From</b>: ${event.startDate.getTime()}<br/><br/>
	<b>To :</b>${event.endDate.getTime()} <br/><br/>
	<b>Description:</b> ${event.description}
	<br/><br/>
	<img src="/public/images/minus.gif" id='p1' onclick = "javascript:swap('c1','p1');"/>
	<b>Associated Tasks</b>
	#{secure.check 'associate tasks to event'}
		<br/>&nbsp;&nbsp;<a href="@{Events.associateTasksPage(event.getEntityId())}">+ Associate Tasks</a><br/>
	#{/secure.check}
	<div id = 'c1' >
		#{if tasks}
			#{list items:tasks, as:'task'}
				<li style="list-style:none">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- <a href="@{Tasks.showTask(task.getEntityId())}">${task.description}</a><br/>
				</li>
			#{/list}
		#{/if}
		#{else}
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;There are no associated tasks.
		#{/else}	
	</div>
	
	<br/><img src="/public/images/minus.gif" id='p2' onclick = "javascript:swap('c2','p2');"/>
	<b>Associated User Stories</b>
	#{secure.check 'associate tasks to event'}
		<br/>&nbsp;&nbsp;<a href="@{Events.associateStoriesPage(event.getEntityId())}">+ Associate User Stories</a><br/>
	#{/secure.check}
	<div id = 'c2' >
		#{if stories}
			#{list items:stories, as:'story'}
			<li style="list-style:none">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- ${story.story}
			</li>
			#{/list}
		#{/if}
		#{else}
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;There are no associated user stories.
		#{/else}
	</div>
	<br/><img src="/public/images/minus.gif" id='p3' onclick = "javascript:swap('c3','p3');"/>
	<b>Associated Users</b><br/>
	#{secure.check 'associate developer to event'}
		<a href="@{Events.developerAssociation(event.getEntityId())}">+ Associate Users</a><br/>
	#{/secure.check}
	<div id='c3'>
		#{if users}
			#{list items:users, as:'user'}
				<li style="list-style:none">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- ${user.firstName} ${user.middleName} ${user.lastName}
				</li>
			#{/list}
		#{/if}
		#{else}
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;There are no associated users.
		#{/else}
	</div>
	<br/><img src="/public/images/minus.gif" id='p4' onclick = "javascript:swap('c4','p4');"/>
	<b>Associated Notes</b><br>
	#{secure.check 'associate note to event'}
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="@{Events.Associatenote(event.getEntityId())}">+ Associate Notes</a><br/>
	#{/secure.check}
	<div id = 'c4' >
		#{if noteassociated}
			#{list items:noteassociated, as:'note'}
				<li style="list-style:none">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- ${note.name}
				</li>
			#{/list}
		#{/if}
		#{else}
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;There are no associated notes.
		#{/else}
	</div>
</div>
<script type="text/javascript">
    function swap(b, p){
        document.getElementById(b).style.display = (document.getElementById(b).style.display == "none") ? "block" : "none";
        document.getElementById(p).src = (document.getElementById(b).style.display == "block") ? "/public/images/minus.gif" : "/public/images/plus.gif";
    }
	$().ready(function(){
        swap('c1', 'p1');
        swap('c2', 'p2');
        swap('c3', 'p3');
        swap('c4', 'p4');
    });
</script>
